package com.project.bean;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.*;
import java.time.LocalDate;

/**
 * 用户类
 */
public class UserBean {
    private int id;
    @NotBlank(message = "用户名必须填写")
    @Pattern(regexp = "[0-9a-zA-Z]{2,}",message = "用户名只能是两位以上的数字或字母")
    private String code;
    @NotBlank(message = "性别必须填写")
    @Pattern(regexp = "[男女]",message = "性别只能填男或女")
    private String sex;
    @Min(value = 2000,message = "工资至少2000")
    @Max(value = 20000,message = "工资不能多于20000")
    private int salary;
    @NotNull(message = "生日必须填写")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    public UserBean() {
    }

    public UserBean(String code, String sex, int salary, LocalDate birthday) {
        this.code = code;
        this.sex = sex;
        this.salary = salary;
        this.birthday = birthday;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", sex='" + sex + '\'' +
                ", salary=" + salary +
                ", birthday=" + birthday +
                '}';
    }
}
